# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread("car.png")
#定位车牌
def color_position(img,output_path):
    colors = [([26,43,46], [34,255,255]),  # 黄色
              ([100,43,46], [124,255,255]),  # 蓝色
              ([35, 43, 46], [77, 255, 255])  # 绿色
              ]
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    for (lower, upper) in colors:
        lower = np.array(lower, dtype="uint8")  # 颜色下限
        upper = np.array(upper, dtype="uint8")  # 颜色上限

        # 根据阈值找到对应的颜色
        mask = cv2.inRange(hsv, lowerb=lower, upperb=upper)
        output = cv2.bitwise_and(img, img, mask=mask)
        k = mark_zone_color(output,output_path)
        if k==1:
            return 1
        # 展示图片
        cv2.imshow("image", img)
        cv2.imshow("image-color", output)
        cv2.waitKey(0)
    return 0


